"""
审计日志 PO
"""

import utils.enum_utils as enum
from models import POBase
from my_typing import *
from utils.data_utils.special import ObjectIdStr
from utils.validator_utils.pydantic_validator.field import (
    CharField,
    IntegerField,
    ListField,
    NormalField,
)


class AuditLogPO(POBase):
    """ 审计日志 | PO """

    exception: bool = NormalField(title="是否发生异常")
    ip: str = CharField(..., title="IP 地址", min_length=7, max_length=15)
    model: enum.Model = NormalField(..., title="模型")
    operation: enum.ModelOperation = NormalField(..., title="操作类型")
    po_id_list: list[ObjectIdStr] = ListField(default_factory=list, title="PO ID 列表")
    request_id: StrOrNone = CharField(title="请求 ID", min_length=28, max_length=28)
    status_code: enum.HTTPStatusCode = IntegerField(..., title="响应状态码")
    trace_id: StrOrNone = CharField(title="链路 ID", min_length=40, max_length=41)
    user_id: ObjectIdStr | None = NormalField(None, title="用户 ID")
